﻿using Eleven_TwoWeek_HD.Model;

namespace Eleven_TwoWeek_HD.DAL
{
    public class StoresDal
    {
        private readonly Mycontext context;

        public StoresDal(Mycontext _context)
        {
            context = _context;
        }
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="G"></param>
        /// <returns></returns>
        public int StoresAdd(Stores G)
        {
            try
            {
                var X = context.Stores.Count(E=>E.StoresId==G.StoresId);
                if (X > 0)
                {
                    return -1;
                }
                context.Stores.Add(G);
                return context.SaveChanges();
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 绑定下拉框
        /// </summary>
        /// <returns></returns>
        public List<Stores> GetShowAll()
        {
            try
            {
                return context.Stores.ToList();
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
